// import { getWorkflowApprovalHistoryProcessInstanceIdByProcessInstanceId } from '@/api';
// import { useExpandProcessStore } from '@/store/expand-process';
// import { assign } from 'lodash-es';

export type TApprovalConclusion = 'PASSED' | 'REJECTED' | 'PROCESSING' | 'REVOKED'; // 通过、驳回、审批中、撤回

// export const useApprovalConclusion = () => {
//   /** 审批结论 PASSED/REJECTED/PROCESSING */
//   const approvalConclusion = ref<TApprovalConclusion | ''>('');
//   /**
//    * @desc 获取最新的审批结论
//    * @param processInstanceId
//    */
//   const getApprovalConclusion = (processInstanceId?: string, callback?: () => void) => {
//     if (processInstanceId) {
//       getWorkflowApprovalHistoryProcessInstanceIdByProcessInstanceId({
//         processInstanceId
//       }).then((res) => {
//         approvalConclusion.value = (res?.historicProcessInstance?.approvalConclusion || '') as any;
//         callback && callback();
//       });
//     }
//   };

//   return {
//     approvalConclusion,
//     getApprovalConclusion
//   };
// };

// export const useCurrentTaskInfo = () => {
//   const route = useRoute();
//   const { taskInstId } = route?.query || {};
//   const expandProcessStore = useExpandProcessStore();
//   const allowSaveFinishComputed = (investmentType?: 'MGU' | 'CCA' | 'AO') =>
//     [investmentType, 'ALL'].includes(expandProcessStore.allowSaveFinish);

//   const currentTaskInfo = computed(() => {
//     const targetTask = expandProcessStore.taskList.find((item: any) => +item.id === Number(taskInstId));

//     return assign(targetTask, expandProcessStore.mguProjectInfo, {
//       currentTaskSaveFinish: allowSaveFinishComputed(targetTask?.investmentType) && targetTask?.taskStatus === 'FINISH'
//     });
//   });
//   /**
//    * @desc 等待数据请求后执行回调
//    * @returns
//    */
//   const onDataLoad = () => {
//     return new Promise<void>((resolve) => {
//       if (currentTaskInfo.value?.id) {
//         resolve();
//         return;
//       }
//       expandProcessStore.onDataLoad().then(resolve);
//     });
//   };

//   return {
//     /** 当前任务信息: 根据url上taskId自动获取 */
//     currentTaskInfo,
//     onDataLoad,
//     allowSaveFinishComputed
//   };
// };
